<template>
  <div>
    <FilterTable
      ref="netReceiptsTable"
      :columns="netReceiptsColumns"
      :dataSource="netReceiptsList"
      :isToperInfo="false"
      :isColumnFilter="false"
      :selectionType="'single'"
      :height="200"
      :onColumnsChange="columns => (this.netReceiptsColumns = columns)"
    ></FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import moment from 'moment';
import { retainValidNumbers } from '@/utils/index';
export default {
  name: 'netReceipts',
  mixins: [dictionary],
  props: ['list', 'resetTable'],
  data() {
    this.BaseTable = null;
    return {
      netReceiptsColumns: this.createNetReceiptsColumns(),
      netReceiptsList: []
    };
  },
  watch: {
    list(val) {
      console.log(val, '---取消---');
      this.insertRecords(val);
    },
    resetTable(val) {
      if (val) {
        this.netReceiptsList = [];
      }
    }
  },
  mounted() {
    this.BaseTable = this.$refs.netReceiptsTable.$refs.pageTable;
    // this.insertRecords(this.list);
  },
  created() {
    // this.dmsFunc = {dmsFuncId:35100010};
    // this.protectRepairFun(this.vehicleDetailsVin);
  },
  methods: {
    createNetReceiptsColumns() {
      let { taxRate } = this.$store.state.repairYxw;
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费对象代码',
          dataIndex: 'PAYMENT_OBJECT_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '收费对象名称',
          dataIndex: 'PAYMENT_OBJECT_NAME',
          width: 150,
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '实收工时费',
          dataIndex: 'REAL_LABOUR_FEE',
          precision: 2,
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.REAL_LABOUR_FEE).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '实收维修材料费',
          dataIndex: 'REAL_REPAIR_PART_FEE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.REAL_REPAIR_PART_FEE).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '实收销售材料费',
          dataIndex: 'REAL_SALES_PART_FEE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.REAL_SALES_PART_FEE).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '实收附加项目费',
          dataIndex: 'REAL_ADD_ITEM_FEE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.REAL_ADD_ITEM_FEE).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '实收装饰项目费',
          dataIndex: 'REAL_BOUTIQUE_ITEM_FEE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '实收装饰材料费',
          dataIndex: 'REAL_BOUTIQUE_PART_FEE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '汇总金额',
          dataIndex: 'SUM_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.SUM_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '实收总金额',
          dataIndex: 'REAL_TOTAL_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.REAL_TOTAL_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '税额',
          dataIndex: 'TAX_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.TAX_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '不含税金额',
          dataIndex: 'NET_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.NET_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '去零金额',
          dataIndex: 'SUB_OBB_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{props.row.SUB_OBB_AMOUNT ? Number(props.row.SUB_OBB_AMOUNT).toFixed(2) : '0.00'}</span>;
          }
          // align:"center"
        },
        {
          title: '应收账款',
          dataIndex: 'RECEIVABLE_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.RECEIVABLE_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '已收账款  ',
          dataIndex: 'RECEIVED_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.RECEIVED_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '未收账款',
          dataIndex: 'NOT_RECEIVED_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{Number(props.row.NOT_RECEIVED_AMOUNT).toFixed(2)}</span>;
          }
          // align:"center"
        },
        {
          title: '是否结清',
          dataIndex: 'PAY_OFF',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.PAY_OFF, '1004')}</span>;
          }
        },
        {
          title: '已开票',
          dataIndex: 'INVOICE_TAG',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.INVOICE_TAG, '1004')}</span>;
          }
        }
      ];
    },
    orderListChangeHandle(val) {},
    insertRecords(list) {
      console.log(JSON.stringify(list), '测试----aaa');
      let newList = list.map(x => {
        // return Object.assign({}, x, { PAY_OFF: 12781002, INVOICE_TAG: 12781002 });
        return Object.assign({}, x);
        // this.$set(x, 'PAY_OFF', 12781002);
      });
      this.netReceiptsList = newList;
      // this.BaseTable.EXECUTE_INSERT(newList);
    }
  }
};
</script>

<style lang="less">
.custom-wrap {
  height: calc(100vh - 145px);
  // position: relative;
}
</style>
